package cn.edu.nenu.control;

import java.util.List;

import javax.ejb.Local;

import cn.edu.nenu.contract.dto.*;
import cn.edu.nenu.contract.eto.*;

@Local
public interface DbQuery {
	/** 
	 * a list of Task Owners level 1 tasks (projects) are returned
	 * @param taskOwnerId - Who is the TaskOwner 
	 */
	public List<SimpleTaskDTO> getLevelOneProjectTasksOf(int taskOwnerId);//DONE ching 4-20  **DONE
	/**
	 *  This method return a list of tasks in project.<br>
	 *  Precondition: a user has been identified and authenticated as Task Owner.
	 *  @param projectId - if null Task Owners level 1 tasks (projects) are returned
	 *  @return List of SimpleTaskDTO - all tasks in project - null if none
	 */	
	public List<SimpleTaskDTO> getProjectTasks(int projectId);//DONE ching 4-20  **DONE
	/**
	 *  This method returns a list of unallocated tasks in project.<br>
	 *  Unallocated tasks are defined as not fully allocated tasks. In other words 
	 *  tasks where the sum of assigned work hours 
	 *  for the task, is less than the required amount of work hours for the task.<br>
	 *  The required amount of work hours for a project is equal to the sum of required 
	 *  work hours for all work tasks in the project and all its sub projects.<br><br>
	 *  Precondition: A user has been identified and authenticated as Task Owner.
	 *  @param projectId - if null Task Owners level 1 tasks (projects) are returned
	 *  @return List of SimpleTaskDTO - all unallocated tasks in project - null if none
	 */	
	public List<SimpleTaskDTO> getUnallocatedTasks(int projectId);//to be done : feng  **DONE
	/**
	 *  Returns all Task Solvers assigned to the task. If task is a project all Task Solvers
	 *  assigned to work tasks (at any level) in project are returned.<br/>
	 *  @param taskId : int - The method is returning a list of Task Solvers assigned to this task.
	 *  @return List of TaskSolverDTO - null if none
	 *  @throws TaskUnknownException - thrown when taskId is not recognized.
	 */	
	public List<TaskSolverDTO> getAssignedTaskSolvers(int taskId)//TODO what is the DTO
			throws TaskUnknownException;
	/**
	 *  Returns a list of Task Solvers still having used less than 
	 *  their maximum allowed work hours next week.<br><br>
	 *  @return List of TaskSolverDTO - null if none
	 */	
	public List<TaskSolverDTO> getAvailableTaskSolvers();//to be done wang wen chang
	/**
	 *  Returns a list of work tasks which are not yet fully allocated.
	 *  @return List of WorkTaskDTO - null if none
	 */	
	public List<WorkTaskDTO> getAvailableWorkTasks();//to be done : cuixin

	/**
	 *  Returns a list of Task Solvers assignments for specified week. Method can get a 
	 *  list of Task Solvers's assignments for either this week or next week. 
	 *  Precondition: User has been identified and authenticated as Task Solver.
	 *  @param week : String - Can be either "this" or "next"
	 *  @return List of AssignmentDTO - null if none
	 */	
	public List<AssignmentDTO> getTaskSolverAssignments(String week);//TODO to be done: liyanjie **DONE
	/**
	 *  Returns a DTO specifying the status of the Task.
	 *  Preconditions: 
	 *  Postconditions:
	 *  @param simpleTaskDTO : TaskStatusDTO
	 *  @return TaskStatusDTO  
	 *  @throws TaskUnknownException - thrown when task is not recognized
	 */
	public TaskStatusDTO getTaskStatus(SimpleTaskDTO simpleTaskDTO)throws TaskUnknownException ;
	/**
	 *  This method return a list of tasks in project.<br>
	 *  If parameter is null a list of Task Owners level 1 tasks (projects) are returned.<br><br>
	 *  Level 1 tasks are defined as being the projects in the root of
	 *  the task tree.<br>
	 *  Preconditions: a user has been identified and authenticated as Task Owner.<br/>
	 *  Postconditions:
	 *  @param projectId - -1 if Task Owners level 1 tasks (projects) are returned
	 *  @return List of SimpleTaskDTO - all tasks in project - null if none
	 *  @throws Exception
	 */		
	public List<AssignmentDTO> getWorkTaskAssignments(SimpleTaskDTO task)throws TaskUnknownException, Exception;

	
	/**
	 *  This method returns a list of unallocated tasks in project.<br/>
	 *  Unallocated tasks are defined as not fully allocated tasks. In other words 
	 *  tasks where the sum of assigned work hours 
	 *  for the task, is less than the required amount of work hours for the task.<br/>
	 *  The required amount of work hours for a project is equal to the sum of required 
	 *  work hours for all work tasks in the project and all its sub projects.<br/><br/>
	 *  Preconditions: A user has been identified and authenticated as Task Owner.<br/>
	 *  Postconditions:
	 *  @param projectId - if null Task Owners level 1 tasks (projects) are returned
	 *  @return List of SimpleTaskDTO - all unallocated tasks in project - null if none
	 *  @throws Exception
	 */		
	public List<AssignmentDTO> getProjectAssignments(SimpleTaskDTO task)throws TaskUnknownException, Exception ;
	/**
	 * Returns a ProjectDTO representing a project with a given id
	 * @param id
	 * @return ProjectDTO
	 * @throws TaskUnknownException, Exception
	 */
	public ProjectDTO getProject(int id) throws TaskUnknownException, Exception ;
	/**
	 *  Returns a list of Task Solvers assignments for specified week current year. 
	 *  Preconditions: User has been identified and authenticated as Task Solver.<br/>
	 *  Postconditions:
	 *  @param week : int - week number in current year
	 *  @return List of AssignmentDTO - null if none of 
	 */		
	public List<AssignmentDTO> getTaskSolverAssignments(int weekNumber) throws Exception;
	/**
	 * Returns a list of DTOs representing the assignments for a given work task
	 * Preconditions:
	 * Postconditions:
	 * @param task : SimpleTaskDTO
	 * @return List<AssignementDTO>
	 * @throws TaskUnknownException,Exception
	 */
	public WorkTaskDTO getWorkTask(int id)throws TaskUnknownException,
	Exception ;

}
